<?php

namespace traits\controller;

use think\facade\View;

trait ViewTraits
{

  /**
   * 模板变量赋值
   * @param $name
   * @param null $value
   * @return View
   */
  protected function assign($name, $value = null)
  {
    return View::assign($name, $value);
  }

  /**
   * 视图过滤
   * @access public
   * @param Callable $filter 过滤方法或闭包
   * @return View
   */
  protected function filter($filter = null)
  {
    return View::filter($filter);
  }

  /**
   * 加载模板输出
   * @param string $template
   * @param array $vars
   * @return string
   * @throws \Exception
   */
  protected function fetch($template = '', $vars = [])
  {
    return View::fetch($template, $vars);
  }

  /**
   * 渲染内容输出
   * @access public
   * @param string $content 内容
   * @param array $vars 模板变量
   * @return string
   */
  protected function display($content, $vars = [])
  {
    return View::display($content, $vars);
  }

}